//index.js
//获取应用实例
const app = getApp()

Page({
	data: {
		num: 1,
		data: [],
		http: getApp().globalData.map,
		id: '',
		px: 0,
		name: '',
		list: '',
		zt:false,
	},
	onLoad: function(e) {
		wx.getStorage({
			key: 'uid',
			success: (e) => {
				console.log(e)
				if(e.data.Vip==1){
					this.setData({
						state:1
					})
				}
			}
		})
		this.setData({
			id: e.id,
			name: e.name
		})
		this.push()
		wx.request({
			url: getApp().globalData.http + 'action=getBrandList',
			success: (res) => {
				console.log(res)
				this.setData({
					list: res.data.data
				})
			}
		})
	},
	push() {
		wx.request({
			url: getApp().globalData.http+'action=searchGoods&pg=' + this.data.num + '&brandID=' + this.data.id +
				'&classID=0&px=' + this.data.px,
			success: (e) => {
				console.log(e)
				let a = this.data.data
				for (let i in e.data.data) {
					a.push(e.data.data[i])
				}
				if (e.data.data.length < 15) {
					this.setData({
						data: a,
						pd: 0
					})
				}
				this.setData({
					data: a
				})
			}
		})
	},
	ovo() {
		console.log(1)
		if (this.data.pd == 1) {
			this.setData({
				num: this.data.num + 1
			})
			this.push()
		}
	},
	dj(e){
		let a=e.currentTarget.dataset
		this.setData({
			id: a.id,
			name: a.name,
			data: [],
			num:1,
			px:0,
			zt:false
		})
		this.push()
	},
	none1(){
		this.setData({
			zt:!this.data.zt
		})
	},
	none(){
		this.setData({
			zt:false,
		})
	},
	xl(){
		this.setData({
			px: 3,
			data: [],
			num:1,
			zt:false
		})
		this.push()
	},
	jiage(){
		if(this.data.px==2){
			this.setData({
				px: 1,
				num:1,
				data: [],
				zt:false
			})
			this.push()
		}else{
			this.setData({
				px: 2,
				data: [],
				zt:false
			})
			this.push()
		}
	}
})
